package org.example.framework.BeanDefinitionMap;

import org.example.framework.BeanDefinition.BeanDefinition;
import org.example.framework.BeanException.BeanException;

import java.util.HashMap;
import java.util.Map;

public class SimpleBeanDefinitionMap implements BeanDefinitionMap {
    private Map<String, BeanDefinition> map;

    public SimpleBeanDefinitionMap(){
        map = new HashMap<>();
    }
    @Override
    public void addBeanDefinition(String id, BeanDefinition beanDefinition){
        map.put(id, beanDefinition);
    }

    @Override
    public void removeBeanDefinition(String beanName) throws Exception{
        map.remove(beanName);
    }

    @Override
    public BeanDefinition getBeanDefinition(String beanName) throws Exception {
        return map.get(beanName);
    }

    @Override
    public int getBeanDefinitionCount(){
        return map.size();
    }

    @Override
    public String[] getBeanDefinitionNames(){
        return map.keySet().toArray(new String[0]);
    }

    @Override
    public boolean containsBeanDefinition(String beanName) {
        return map.containsKey(beanName);
    }
}